<%@ Page Language="C#" Theme="Defaultsys" AutoEventWireup="true" CodeFile="ContactPageAdministration.aspx.cs"
    Inherits="ContactPageAdministration" Title="Rapport Plan System - Contact page administration"
    MasterPageFile="~/MasterPage.master" %>

<%@ MasterType VirtualPath="~/MasterPage.master" %>
<asp:Content runat="server" ID="contentHolder" ContentPlaceHolderID="ContentPlaceHolder1">
    <link rel="stylesheet" type="text/css" media="all" href="jscripts/date/calendar-tas.css" title="win2k-cold-1" />

    <script type="text/javascript" src="jscripts/date/calendar.js"></script>

    <script type="text/javascript" src="jscripts/date/calendar-setup.js"></script>

    <script type="text/javascript">
    function ValidateDelete()
    {
        nrOfRecord = document.getElementById('ctl00_ContentPlaceHolder1_txtHidden').value;
        for (i = 0; i < nrOfRecord+2; i++)
        {
            object = document.getElementById('ctl00_ContentPlaceHolder1_grdPageFields_ctl'+((i<10)?('0'+i):(i+''))+'_ckRemove');
            if (object!= null)
            {
                if (object.checked)
                {
                    return confirm("Are you sure you want to delete these fields?"); 
                }        
            }      
        }

        document.getElementById('lblError').style.visibility = 'visible'; 
        return false;
    }
    
     function ValidateSymbols(oSrc, args)
        {
            args.IsValid = true;
            str = args.Value;
            for (i=0; i<str.length; i++ )
            { 
                if ((str.charAt(i) < '0') || (str.charAt(i) > '9'))
                    args.IsValid = false;
            }
        }  
    
    </script>

    <table border="0" width="100%" cellpadding="0" cellspacing="0">
        <tr>
            <td class="contTable">
                <asp:GridView ID="grdPageFields" SkinID="gvGrid" runat="server" AllowPaging="false"
                    AutoGenerateColumns="False" OnRowCommand="ModifyField" DataKeyNames="ContactPageFieldId">
                    <Columns>
                        <asp:BoundField HeaderText="Id" DataField="ContactPageFieldId" SortExpression="ContactPageFieldId"
                            Visible="false"/>
                            
                        <asp:BoundField HeaderText="Property" DataField="Name" SortExpression="Name" 
                            HeaderStyle-HorizontalAlign="Left" ItemStyle-HorizontalAlign="Left"/>
                            
                        <asp:BoundField HeaderText="Type" DataField="Type" SortExpression="Type"
                            HeaderStyle-HorizontalAlign="Left" ItemStyle-HorizontalAlign="Left" />
                            
                        <asp:TemplateField HeaderText="Order" HeaderStyle-HorizontalAlign="Left" ItemStyle-HorizontalAlign="Left">
                            <ItemTemplate>
                                <asp:TextBox ID="txtOrder" runat="server" Text='<%# Eval("OrderIndex") %>'></asp:TextBox>
                                <asp:CustomValidator ID="CustomValidator6" runat="server" ClientValidationFunction="ValidateSymbols"
                                    ControlToValidate="txtOrder" Display="Dynamic" ErrorMessage="*" SetFocusOnError="True"></asp:CustomValidator>
                            </ItemTemplate>
                            <ItemStyle HorizontalAlign="Left" />
                        </asp:TemplateField>
                        
                        <asp:TemplateField HeaderText="Edit"
                            HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Center">
                            <ItemTemplate>
                                <asp:Button ID="btnEdit" runat="server" Text="Edit" CommandArgument='<%# Eval("ContactPageFieldId") %>' />
                            </ItemTemplate>
                            <ItemStyle HorizontalAlign="Center" />
                        </asp:TemplateField>
                        
                        <asp:TemplateField HeaderText="Remove" HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Center">
                            <ItemTemplate>
                                <asp:CheckBox ID="ckRemove" runat="server"></asp:CheckBox>
                            </ItemTemplate>
                            <ItemStyle HorizontalAlign="Center" />
                            
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="Id" Visible="false">
                            <ItemTemplate>
                                <asp:TextBox ID="id" runat="server" Visible="false" Text='<%# Eval("ContactPageFieldId") %>'></asp:TextBox>
                            </ItemTemplate>
                        </asp:TemplateField>
                    </Columns>
                </asp:GridView>

                <script type="text/javascript">

  for (i=0; i<=9; i++){
    if (document.getElementById("ctl00_ContentPlaceHolder1_grdPageFields_ctl0"+i+"_txtDateTimeId")!= null){
    Calendar.setup({
        inputField     :    "ctl00_ContentPlaceHolder1_grdPageFields_ctl0"+i+"_txtDateTimeId",     // id of the input field
        ifFormat       :    "%m/%d/%Y",    // format of the input field
        button         :    "ctl00_ContentPlaceHolder1_grdPageFields_ctl0"+i+"_dateId",  // trigger for the calendar (button ID)
        singleClick    :    true
    });
    }
  }
    
                </script>

                <!--
     <table border="1" width="100%">
         <tr>
             <td>Property
             </td>
             <td>Type</td>
             <td width="5%">Order</td>
             <td width="5%">Edit</td>
             <td width="5%">Remove</td>
         </tr>
         <tr>
             <td>
                 First name:</td>
             <td>
                 <asp:TextBox ID="txtFirstName" runat="server"></asp:TextBox></td>
             <td>
                 <asp:TextBox ID="txtOrderField1" runat="server" Width="36px">1</asp:TextBox>
                 </td>
             <td >
                 <asp:Button ID="btnEdit1" runat="server" Text="Edit"/></td>
             <td align="center">
                 <asp:CheckBox ID="ckField" runat="server" /></td>
         </tr>
         <tr>
             <td>
                 Second name:</td>
             <td>
                 <asp:TextBox ID="txtSecondName" runat="server"></asp:TextBox></td>
             <td>
                 <asp:TextBox ID="txtOrderIndex2" runat="server" Width="36px">2</asp:TextBox></td>
             <td width="5%"><asp:Button ID="Button1" runat="server" Text="Edit" /></td>
             <td  align="center">
                 <asp:CheckBox ID="ckField1" runat="server" /></td>
         </tr>
         <tr>
             <td>
                 Notes:</td>
             <td>
                 <asp:TextBox ID="txtNotes" runat="server"></asp:TextBox></td>
             <td>
                 <asp:TextBox ID="txtOrderIndex3" runat="server" Width="36px">3</asp:TextBox></td>
             <td width="5%"><asp:Button ID="Button2" runat="server" Text="Edit" /></td>
             <td align="center">
                 <asp:CheckBox ID="ckField2" runat="server" /></td>
         </tr>
         <tr>
             <td>
                 Background:
             </td>
             <td>
                 <asp:TextBox ID="txtBackground" runat="server" TextMode="Password" Width="149px"></asp:TextBox></td>
             <td>
                 <asp:TextBox ID="txtOrderIndex4" runat="server" Width="36px">4</asp:TextBox></td>
             <td width="5%"><asp:Button ID="Button3" runat="server" Text="Edit" /></td>
             <td align="center">
                 <asp:CheckBox ID="ckField3" runat="server" /></td>
         </tr>
         <tr>
             <td>
                 Value:</td>
             <td>
                 <asp:DropDownList ID="DropDownList1" runat="server" Width="159px">
                     <asp:ListItem>up to 100</asp:ListItem>
                     <asp:ListItem>100-200</asp:ListItem>
                     <asp:ListItem>more than 200</asp:ListItem>
                 </asp:DropDownList></td>
             <td>
                 <asp:TextBox ID="txtOrderIndex5" runat="server" Width="36px">5</asp:TextBox></td>
             <td width="5%"><asp:Button ID="Button4" runat="server" Text="Edit" /></td>
             <td align="center">
                 <asp:CheckBox ID="ckField4" runat="server" /></td>
         </tr>
     </table>
     -->
                <asp:Button ID="btnAddNewField" runat="server" Text="Add new field" OnClick="AddNewField" />
                <asp:Button ID="btnRemoveFields" runat="server" Text="Remove fields" OnClick="RemoveFields" />
                <asp:Button ID="btnModifyFieldOrder" runat="server" Text="Modify field order" OnClick="ModifyFieldOrder" />&nbsp;<br />
                <asp:HiddenField ID="txtHidden" runat="server" />
                <div id="lblError" style="color: Red; visibility: hidden">
                    No field is selected</div>
            </td>
        </tr>
    </table>
</asp:Content>
